package com.example.smartwaterapi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smartwaterapi.entity.WaterAchievement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 饮水成就Mapper接口
 */
@Mapper
public interface WaterAchievementMapper extends BaseMapper<WaterAchievement> {
    
    /**
     * 根据成就代码获取成就
     */
    @Select("SELECT * FROM water_achievements WHERE achievement_code = #{code} AND is_active = 1")
    WaterAchievement getAchievementByCode(@Param("code") String code);
    
    /**
     * 获取指定类型的成就列表
     */
    @Select("SELECT * FROM water_achievements WHERE type = #{type} AND is_active = 1 ORDER BY difficulty, sort_order")
    List<WaterAchievement> getAchievementsByType(@Param("type") String type);
    
    /**
     * 获取指定难度等级的成就列表
     */
    @Select("SELECT * FROM water_achievements WHERE difficulty = #{difficulty} AND is_active = 1 ORDER BY type, sort_order")
    List<WaterAchievement> getAchievementsByDifficulty(@Param("difficulty") Integer difficulty);
    
    /**
     * 获取所有可重复获得的成就
     */
    @Select("SELECT * FROM water_achievements WHERE is_repeatable = 1 AND is_active = 1")
    List<WaterAchievement> getRepeatableAchievements();
    
    /**
     * 获取所有非隐藏成就
     */
    @Select("SELECT * FROM water_achievements WHERE is_hidden = 0 AND is_active = 1 ORDER BY difficulty, sort_order")
    List<WaterAchievement> getVisibleAchievements();
    
    /**
     * 获取所有隐藏成就
     */
    @Select("SELECT * FROM water_achievements WHERE is_hidden = 1 AND is_active = 1")
    List<WaterAchievement> getHiddenAchievements();
} 